package com.productivity.model.common;

import java.io.Serializable;

public class Vector3D implements Serializable {
	protected float[] coord = new float[3];
	public Vector3D() {
		setX(0);
		setY(0);
		setZ(0);
	}
	public Vector3D(float x, float y, float z) {
		setX(x);
		setY(y);
		setZ(z);
	}
	public Vector3D(Vector3D start, Vector3D end, float frac) {
		setX(start.getX() + ((end.getX()-start.getX())*frac));
		setY(start.getY() + ((end.getY()-start.getY())*frac));
		setZ(start.getZ() + ((end.getZ()-start.getZ())*frac));
	}
	public Vector3D addVector(Vector3D vec) {
		return new Vector3D(vec.getX()+getX(), vec.getY()+getY(),vec.getZ()+getZ());
	}
	public Vector3D scale(float scale) {
		return new Vector3D(getX()*scale,getY()*scale, getZ()*scale);
	}
	public float[] getArray() {
		return coord;
	}
	public float getX() {
		return coord[0];
	}
	public int getIntX() {
		return (int)coord[0];
	}
	public void setX(float x) {
		this.coord[0] = x;
	}
	public float getY() {
		return coord[1];
	}
	public int getIntY() {
		return (int)coord[1];
	}
	public void setY(float y) {
		this.coord[1] = y;
	}
	public float getZ() {
		return coord[2];
	}
	public int getIntZ() {
		return (int)coord[2];
	}
	public void setZ(float z) {
		this.coord[2] = z;
	}
	public String toString() {
		return String.format("%.5ff", getX()) + ", " + String.format("%.5ff", -getY()) + ", " + String.format("%.5ff", getZ());
	}
}
